for (int i = 0; i < dataGridView1.RowCount-1; i++)
if (radioButton1.Checked == true)
{
string strConn = @"Data Source='" + dbconfig.tb1 + "';Initial Catalog='" + dbconfig.tb2 + "';user='" + dbconfig.tb3 + "';pwd='" + dbconfig.tb4 + "'";
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT CODE FROM LG_" + dbconfig.tb5 + "_table", conn);
cmd.ExecuteNonQuery();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
if (reader["CODE"].ToString() != dataGridView1.Rows[i++].Cells[2].Value.ToString())
{
MessageBox.Show(dataGridView1.Rows[i].Cells[2].Value.ToString());
}
}
conn.Close();
}
}
Compare value of datagrid with value of selected from database
231224-May-2014
Demir ACAR
27-May-2014I fill to datagrid with excel and want to check data in datagrid and sql value,
For example , My Grid Results
GRID_DATA DB_DATA
ABD GERMANY
GERMANY ABD
ITALY UKRAINE
So I want to catch ITALY due to does not exists database.
Thanks in advance
Note : I fill to grid with excel , no datatables or others.
Manmohan Jha
27-May-2014Please elaborate your question...